package com.kanshu.ksgb.fastread.doudou.module.reader.view;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.RelativeLayout;

/**
 * Title:
 * Description:
 * Copyright: Copyright(c)2018
 * Company: 看书网
 * CreateTime: 2018/6/20 11:48
 *
 * @author EvanHe
 * @version 3.0
 */
public class VirtualKeyLayout extends RelativeLayout {

    private ILayoutKeyChange mLayoutKeyChange;

    public VirtualKeyLayout(Context context) {
        super(context);
    }

    public VirtualKeyLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public VirtualKeyLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    /**
     * @param changed 布局发生改变 ture 没有改变False
     */
    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        super.onLayout(changed, l, t, r, b);
        Log.e("onLayout", "onLayout: b "+b);
        if (changed && mLayoutKeyChange != null)
            mLayoutKeyChange.onLayoutKeyChange(b);
    }


    public void setonLayoutKeyChange(ILayoutKeyChange layoutKeyChange) {
        mLayoutKeyChange = layoutKeyChange;
    }


    public interface ILayoutKeyChange {
        /**
         * 虚拟键盘状态监听
         *
         * @param b 布局距离底部的布局
         */
        void onLayoutKeyChange(int b);
    }
}
